home *** CD-ROM | disk | FTP | other *** search
- // *********************** Prog4.C ***********************
- // A program which shows the usage of TPSurface
- #include <TPSurface.h>
- #include <splineOutput.h>
-
- int main()
- {
- const real Pi = M_PI; // M_PI is defined in math.h
- // surface data to be interpolated:
- Vec(real) gridlines(9); gridlines.fill(-4.0/3.0, 4.0/3.0);
- ArrayGenSimple(real) funcval(9,9);
- for (int i = 1; i <= 9; i++)
- for (int j = 1; j <= 9; j++) funcval(i,j)= sin(gridlines(i)*gridlines(j));
-
- KnotVec k(7); // knot vector for the parameters (same for both parameters)
- k.fill(-sqrt(Pi),sqrt(Pi)); k.regulate(4);
- SplineSpace space(k,4); // cubic spline
-
- TPSurface spline_surface;
- spline_surface.redim(space,space); // same grid in both directions
- spline_surface.interpolation(gridlines,gridlines,funcval);
-
- // evaluate the spline function on a lattice for later plotting of the
- // fitted surface:
- Vec(real) newgridlines(41);
- newgridlines.fill(-1.5,1.5); // lattice coordinates
-
- createPlotmtvFile(spline_surface,newgridlines,newgridlines,
- "FILE=surface.mtv");
- return 0;
- }
-
-
-
-
-